/**
 * Created by admin on 2018/7/27.
 */
import post from '../post/post-proxy'

export default {
  /**
   * 登入
   * @param loginName
   * @param pwd
   * @param type
   * @returns {Promise}
   */
  loginPost: (loginName, pwd, type) => {
    return post('oauth', '/fjxhx/gis/system/login', {
      'loginName': loginName,
      'password': pwd,
      'type': type
    })
  },
  /**
   * 获取道路列表
   * @author chend(cdhahaha@163.com)
   * @createDate 2018-09-17
   * @param      {Number}   options._page     展示数
   * @param      {Number}   options._pageSize 当前页
   */
  metaDataRoadListGet ({_page, _pageSize, cn, streetId}) {
    let params = {}
    if (_page) {
      params['_page'] = _page
    }
    if (_pageSize) {
      params['_pageSize'] = _pageSize
    }
    if (cn) {
      params['cn'] = cn
    }
    if (streetId) {
      params['streetId'] = streetId
    }
    return post('inner', 'ehome.metadata.road.list.get', params)
  },
  /**
   * 获取县街道元数据列表
   * @author chend(cdhahaha@163.com)metadataStreetListGet
   * @createDate 2018-09-18
   * @param      {String}   options.streetId 街道Id
   * @param      {String}   options.cn       中文描述
   * @return     {Promise}
   */
  metadataStreetListGet ({districtId, cn}) {
    var params = {districtId}
    if (cn) {
      params['cn'] = cn
    }
    return post('inner', 'ehome.metadata.street.list.get', params)
  },
  /**
   * 获取区县元数据列表
   * @author chend(cdhahaha@163.com)
   * @createDate 2018-09-18
   * @param      {String}   options.cityId 市Id
   * @param      {String}   options.cn       中文描述
   * @return     {Promise}
   */
  metadataDistrictListGet ({cityId, cn}) {
    var params = {}
    if (cityId) {
      params['cityId'] = cityId
    }
    if (cn) {
      params['cn'] = cn
    }
    return post('inner', 'ehome.metadata.district.list.get', params)
  },
  /**
   * 获取城市元数据列表
   * @author chend(cdhahaha@163.com)
   * @createDate 2018-09-18
   * @param      {String}   options.provinceId 省Id
   * @param      {String}   options.cn         中文描述
   * @return     {Promise}
   */
  metadataCityListGet ({provinceId, cn}) {
    var params = {provinceId}
    if (cn) {
      params['cn'] = cn
    }
    return post('inner', 'ehome.metadata.city.list.get', params)
  },
  /**
   * 获取中国 省 直辖市 特区 州 元数据列表
   * @author chend(cdhahaha@163.com)
   * @createDate 2018-09-18
   * @param      {[type]}   options.cn [description]
   * @return     {[type]}              [description]
   */
  metaDataProvinceListGet ({cn}) {
    var params = {}
    if (cn) {
      params['cn'] = cn
    }
    return post('inner', 'ehome.metadata.province.list.get', params)
  },
  /**
   * 获取2D图源
   * @returns {Promise}
   */
  mapSource2DGet: () => {
    return post('outer', '/fjxhx/gis/map/source/2d/get', {})
  },
  /**
   * 获取3D图源
   * @returns {Promise}
   */
  mapSource3DGet: () => {
    return post('outer', '/fjxhx/gis/map/source/3d/get', {})
  },
  /**
   * 查找锚点类型分页列表
   * @author chend(cdhahaha@163.com)
   * @createDate 2018-07-30
   * @param      {[type]}   options.page     当前显示页，取值范围
   * @param      {[type]}   options.pageSize  每页显示条数，取值范围[1,100]
   */
  anchorTypeListGet: ({page, pageSize}) => {
    return post('outer', '/fjxhx/gis/anchor/type/list/get', {
      'page': page,
      'pageSize': pageSize
    })
  },
  anchorAdd ({
    anchorDesc,
    anchorName,
    anchorTypeId,
    areaCityId,
    areaCountyId,
    areaTownId,
    areaWayId,
    height,
    latitude,
    longitude,
    mapScale
  }) {
    let params = {
      anchorName,
      anchorTypeId,
      areaTownId,
      areaWayId,
      latitude,
      longitude,
      mapScale
    }
    if (anchorDesc) {
      params['anchorDesc'] = anchorDesc
    }
    if (areaCityId) {
      params['areaCityId'] = areaCityId
    }
    if (areaCountyId) {
      params['areaCountyId'] = areaCountyId
    }
    if (height) {
      params['height'] = height
    }
    return post('outer', '/fjxhx/gis/anchor/add', params)
  },
  /**
   * 锚点类型搜索
   * @author chend(cdhahaha@163.com)
   * @createDate 2018-09-14
   * @param      {String}   options.anchorTypeName 锚点类型名称
   * @param      {String}   options.mapModel2d     是否支持2d
   * @param      {String}   options.mapModel3d     是否支持3d
   * @return     {Promise}
   */
  anchorTypeListSearch: ({anchorTypeName, mapModel2d, mapModel3d}) => {
    var params = {}
    if (anchorTypeName) {
      params['anchorTypeName'] = anchorTypeName
    }
    if (mapModel3d) {
      params['mapModel3d'] = mapModel3d
    }
    if (mapModel2d) {
      params['mapModel2d'] = mapModel2d
    }
    return post('outer', '/fjxhx/gis/anchor/type/search/list/get', params)
  },
  /**
   * 模糊搜索锚点
   * @author chend(cdhahaha@163.com)
   * @createDate 2018-09-14
   * @param      {String}   options.areaCityName    [城市]
   * @param      {String}   options.areaCountyName  [区县]
   * @param      {String}   options.areaTownName    [街道/乡/镇]
   * @param      {String}   options.areaWayName     [道路]
   * @param      {String}   options.createBeginDate [创建开始时间]
   * @param      {String}   options.createEndDate   [创建结束时间]
   * @param      {String}   options.creator         [创建人]
   * @param      {String}   options.isMapModel2d    [是否适用于2D模型]
   * @param      {String}   options.isMapModel3d    [否适用于3D模型]
   * @param      {String}   options.mapScale        [地图比例]
   * @param      {String}   options.page            [当前显示页]
   * @param      {String}   options.pageSize        [每页显示条数]
   * @return     {Promise}
   */
  anchorSearchList: ({
    areaCityName,
    areaCountyName,
    areaTownName,
    areaWayName,
    createBeginDate,
    createEndDate,
    creator,
    isMapModel2d,
    isMapModel3d,
    mapScale,
    page,
    pageSize,
    anchorTypeId
  }) => {
    var params = {
      page,
      pageSize
    }
    if (areaCityName) {
      params['areaCityName'] = areaCityName
    }
    if (areaCountyName) {
      params['areaCountyName'] = areaCountyName
    }
    if (areaTownName) {
      params['areaTownName'] = areaTownName
    }
    if (areaWayName) {
      params['areaWayName'] = areaWayName
    }
    if (createBeginDate) {
      params['createBeginDate'] = createBeginDate
    }
    if (createEndDate) {
      params['createEndDate'] = createEndDate
    }
    if (creator) {
      params['creator'] = creator
    }
    if (isMapModel2d) {
      params['isMapModel2d'] = isMapModel2d
    }
    if (isMapModel3d) {
      params['isMapModel3d'] = isMapModel3d
    }
    if (mapScale) {
      params['mapScale'] = mapScale
    }
    if (anchorTypeId) {
      params['anchorTypeId'] = anchorTypeId
    }
    return post('outer', '/fjxhx/gis/anchor/search/list/get', params)
  },
  /**
   * 查找锚点类型2d列表
   * @returns {Promise}
   */
  anchorType2DListGet: () => {
    return post('outer', '/fjxhx/gis/anchor/type/2d/list/get', {})
  },
  /**
   * 查找锚点类型3d列表
   * @returns {Promise}
   */
  anchorType3DListGet: () => {
    return post('outer', '/fjxhx/gis/anchor/type/3d/list/get', {})
  },
  /**
   * 根据锚点类型id查找详细信息
   * @param anchorTypeId
   * @returns {Promise}
   */
  anchorTypeDetailGet: (anchorTypeId) => {
    return post('outer', '/fjxhx/gis/anchor/type/get', {anchorTypeId})
  },
  /**
   * 获取增量锚点列表
   * @param actualMapScale 当前地图比例尺
   * @param anchorTypeId 锚点元素名图标ID
   * @param isMapModel2d 是否为2D图源:T/F
   * @param isShowNotEdit 是否显示未编辑锚点
   * @param isShowNotRelation 是否显示未关联锚点：
   * @param mapScaleList 地图比例尺列表：200/500/800
   * @param nowLatitudeEnd
   * @param nowLatitudeStart
   * @param nowLongitudeEnd
   * @param nowLongitudeStart
   * @param oldLatitudeEnd
   * @param oldLatitudeStart
   * @param oldLongitudeEnd
   * @param oldLongitudeStart
   */
  anchorPointMoreListGet: ({actualMapScale, anchorTypeId, isMapModel2d, isShowNotEdit, isShowNotRelation, mapScaleList, nowLatitudeEnd, nowLatitudeStart, nowLongitudeEnd, nowLongitudeStart, oldLatitudeEnd, oldLatitudeStart, oldLongitudeEnd, oldLongitudeStart}) => {
    let params = {
      actualMapScale,
      isMapModel2d,
      nowLatitudeEnd,
      nowLatitudeStart,
      nowLongitudeEnd,
      nowLongitudeStart
    }
    if (oldLatitudeEnd) {
      params.oldLatitudeEnd = oldLatitudeEnd
    }
    if (oldLatitudeStart) {
      params.oldLatitudeStart = oldLatitudeStart
    }
    if (oldLongitudeEnd) {
      params.oldLongitudeEnd = oldLongitudeEnd
    }
    if (oldLongitudeStart) {
      params.oldLongitudeStart = oldLongitudeStart
    }
    if (anchorTypeId) {
      params.anchorTypeId = anchorTypeId
    }
    if (isShowNotEdit) {
      params.isShowNotEdit = isShowNotEdit
    }
    if (isShowNotRelation) {
      params.isShowNotRelation = isShowNotRelation
    }
    if (mapScaleList.length) {
      params.mapScaleList = mapScaleList
    }
    // params.mapScaleList = ['800', '200', '500']
    return post('outer', '/fjxhx/gis/anchor/more/list/get', params)
  },
  /**
   * 2D锚点添加
   * @returns {Promise}
   */
  anchorPoint2DAdd: (anchorTypeId, latitude, longitude) => {
    return post('outer', '/fjxhx/gis/anchor/2d/add', {anchorTypeId, latitude, longitude})
  },
  /**
   * 更新2d锚点
   * @author chend(cdhahaha@163.com)
   * @createDate 2018-09-17
   * @param      {String}   options.anchorDesc   锚点备注
   * @param      {String}   options.anchorId     锚点ID
   * @param      {String}   options.anchorName   锚点名称
   * @param      {String}   options.areaCityId   城市Id
   * @param      {String}   options.areaCountyId 区县Id
   * @param      {String}   options.areaTownId   街道/乡/镇Id
   * @param      {String}   options.areaWayId    道路Id
   * @param      {String}   options.latitude     纬度
   * @param      {String}   options.longitude    经度
   * @param      {String}   options.mapScale     地图比例尺
   * @return     {Promise}
   */
  anchorPoint2DUpdate: ({
    anchorDesc,
    anchorId,
    anchorName,
    areaCityId,
    areaCountyId,
    areaTownId,
    areaWayId,
    latitude,
    longitude,
    mapScale,
    anchorTypeId
  }) => {
    mapScale = parseInt(mapScale)
    let params = {
      anchorId,
      anchorName
    }
    if (anchorTypeId) {
      params.anchorTypeId = anchorTypeId
    }
    if (latitude) {
      params.latitude = latitude
    }
    if (mapScale) {
      params.mapScale = mapScale
    }
    if (longitude) {
      params.longitude = longitude
    }
    if (areaCityId) {
      params.areaCityId = areaCityId
    }
    if (areaCountyId) {
      params.areaCountyId = areaCountyId
    }
    if (areaTownId) {
      params.areaTownId = areaTownId
    }
    if (areaWayId) {
      params.areaWayId = areaWayId
    }
    if (anchorDesc) {
      params.anchorDesc = anchorDesc
    }
    return post('outer', '/fjxhx/gis/anchor/2d/update', params)
  },
  /**
   * 更新2d锚点
   * @author chend(cdhahaha@163.com)
   * @createDate 2018-09-17
   * @param      {String}   options.anchorDesc   锚点备注
   * @param      {String}   options.anchorId     锚点ID
   * @param      {String}   options.anchorName   锚点名称
   * @param      {String}   options.areaCityId   城市Id
   * @param      {String}   options.areaCountyId 区县Id
   * @param      {String}   options.areaTownId   街道/乡/镇Id
   * @param      {String}   options.areaWayId    道路Id
   * @param      {String}   options.latitude     纬度
   * @param      {String}   options.longitude    经度
   * @param      {String}   options.mapScale     地图比例尺
   * @return     {Promise}
   */
  anchorPoint3DUpdate: ({
    anchorDesc,
    anchorId,
    anchorName,
    areaCityId,
    areaCountyId,
    areaTownId,
    areaWayId,
    latitude,
    longitude,
    mapScale,
    height
  }) => {
    mapScale = parseInt(mapScale)
    let params = {
      anchorId,
      anchorName,
      height
    }
    if (latitude) {
      params.latitude = latitude
    }
    if (mapScale) {
      params.mapScale = mapScale
    }
    if (longitude) {
      params.longitude = longitude
    }
    if (areaCityId) {
      params.areaCityId = areaCityId
    }
    if (areaCountyId) {
      params.areaCountyId = areaCountyId
    }
    if (areaTownId) {
      params.areaTownId = areaTownId
    }
    if (areaWayId) {
      params.areaWayId = areaWayId
    }
    if (anchorDesc) {
      params.anchorDesc = anchorDesc
    }
    return post('outer', '/fjxhx/gis/anchor/3d/update', params)
  },
  /**
   * 3D锚点添加
   * @returns {Promise}
   */
  anchorPoint3DAdd: (anchorTypeId, height, latitude, longitude) => {
    return post('outer', '/fjxhx/gis/anchor/3d/add', {anchorTypeId, height, latitude, longitude})
  },
  anchorBatchChecked (file) {
    return post('upload', '/fjxhx/gis/anchor/batch/check', file)
  },
  anchorBatchAdd (file) {
    return post('upload', '/fjxhx/gis/anchor/batch/add', file)
  },
  /**
   * 锚点 删除
   * @param anchorId
   * @returns {Promise}
   */
  anchorPointDelete: (anchorId) => {
    return post('outer', '/fjxhx/gis/anchor/delete', {anchorId})
  },
  /**
   * 批量删除锚点
   * @author chend(cdhahaha@163.com)
   * @createDate 2018-09-19
   * @param      {String}   options.anchorIdList 锚点id数组
   */
  anchorPointBatchDelete ({anchorIdList}) {
    return post('outer', '/fjxhx/gis/anchor/batch/delete', {anchorIdList})
  },
  /**
   * 获取锚点详情
   * @param anchorId
   * @returns {Promise}
   */
  anchorPointDetailGet: (anchorId) => {
    return post('outer', '/fjxhx/gis/anchor/get', {anchorId})
  },
  anchorRelationGet ({relationIdList}) {
    return post('outer', '/fjxhx/gis/anchor/relation/get', {relationIdList})
  },
  /**
   * 获取锚点维护日志
   * @author chend(cdhahaha@163.com)
   * @createDate 2018-09-21
   * @param      {String}   options.anchorTypeId 锚点类型Id
   * @param      {Number}   options.latitude     锚点纬度坐标
   * @param      {Number}   options.longitude    锚点经度坐标
   */
  anchorLogListGet ({createBeginDate, createEndDate, page, pageSize}) {
    let params = {
      page,
      pageSize
    }
    if (createBeginDate) {
      params['createBeginDate'] = createBeginDate
    }
    if (createEndDate) {
      params['createEndDate'] = createEndDate
    }
    return post('outer', '/fjxhx/gis/anchor/log/list/get', params)
  },
  /**
   * 修改锚点关联信息
   * @param anchorId
   * @param relationBusinessData
   * @returns {Promise}
   */
  anchorPointRelationUpdate: (anchorId, relationBusinessData) => {
    return post('outer', '/fjxhx/gis/anchor/relation/update', {anchorId, relationBusinessData})
  },
  /**
   * 数据字典明细列表
   * @param dictCode  dictCode (string): 字典编码,比例尺:MAP_SCALE;地图图源:MAP_SOURCE;地图模型:MAP_MODEL;地图中心定位类型:MAP_CENTER_LOCATION_TYPE;地图中心定位类型:WINDOW_TYPE;用户类型:USER_TYPE;用户状态:USER_STATUS;用户角色:USER_ROLE;删除状态:DELETED
   * @returns {Promise}
   */
  dictDetailList: ({dictCode}) => {
    return post('outer', '/fjxhx/gis/dict/detail/list/get', {dictCode})
  },
  getMapsourceArea () {
    return post('outer', '/fjxhx/gis/map/source/area/get', {})
  },
  roadBatchCheck (param) {
    // let params = {}
    return post('inner', 'ehome.metadata.batch.check.road', param)
  }
}
